home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / BORL_TIP / TI100 / TI668.ASC < prev    next >
Text File  |  1992-08-12  |  5KB  |  265 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Turbo Pascal                           NUMBER  :  668
  9.   VERSION  :  6.0
  10.        OS  :  MS/PC DOS
  11.      DATE  :  August 12, 1992                          PAGE  :  1/4
  12.  
  13.     TITLE  :  Dual Input Lines in Turbo Vision
  14.  
  15.  
  16.  
  17.  
  18.   {
  19.  
  20.   This program will create a record structure of two strings
  21.   and initialize them with data then read them into a
  22.   TInputLine.  The program will use the SetData and GetData
  23.   methods to load and store data from the TInputLine Object.
  24.  
  25.   }
  26.   {$X+}
  27.   program DualInputExample;
  28.  
  29.   uses Objects, Drivers, Views, Menus, Dialogs, App;
  30.  
  31.   const
  32.     cmNewDialog     = 100;
  33.     hcMyDialog      = 300;
  34.  
  35.   type
  36.     MyData = record
  37.       Mystr1:String[10];              { Create a Record Structure }
  38.       MyStr2:String[10];              { for Input Lines in Dialog }
  39.       end;
  40.  
  41.   var
  42.    RMyData: MyData;                   { Declare the Structure }
  43.  
  44.   type
  45.     TMyApp = object(TApplication)
  46.       constructor Init;
  47.       procedure HandleEvent(var Event: TEvent); virtual;
  48.       procedure InitMenuBar; virtual;
  49.       procedure NewDialog;
  50.     end;
  51.  
  52.     PDemoDialog = ^TDemoDialog;
  53.     TDemoDialog = object(TDialog)
  54.      Procedure HandleEvent(var Event:TEvent);virtual;
  55.     end;
  56.  
  57.   constructor TMyApp.Init;
  58.   var
  59.     R : TRect;
  60.   begin
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Turbo Pascal                           NUMBER  :  668
  75.   VERSION  :  6.0
  76.        OS  :  MS/PC DOS
  77.      DATE  :  August 12, 1992                          PAGE  :  2/4
  78.  
  79.     TITLE  :  Dual Input Lines in Turbo Vision
  80.  
  81.  
  82.  
  83.  
  84.     TApplication.Init;                { Initialize data }
  85.     RMydata.MYstr1:='What';
  86.     RMydata.MYstr2:='Cheese';
  87.     GetExtent(R);
  88.     Dec(R.B.X);
  89.     R.A.X := R.B.X - 9; R.A.Y := R.B.Y - 1;
  90.   end;
  91.   { TMyApp }
  92.  
  93.   Procedure TDemoDialog.HandleEvent(var Event:TEvent);
  94.   begin
  95.    TDialog.HandleEvent(Event);
  96.     if Event.What = EvCommand then
  97.       begin
  98.        if event.what = EvCommand then
  99.        case Event.Command of
  100.          cmOK:begin
  101.                 GetData(RMyData); { This will retrieve the }
  102.                                   { information corresponding to }
  103.                                   { a previous SetData and load }
  104.                                   { the changed values in the }
  105.                                   { record structure }
  106.                 TDialog.Done;
  107.               end;
  108.          cmCancel:TDialog.Done;
  109.         end
  110.          else
  111.          Exit;
  112.        end;
  113.    clearEvent(Event);
  114.   end;
  115.  
  116.   procedure TMyApp.HandleEvent(var Event: TEvent);
  117.   begin
  118.     TApplication.HandleEvent(Event);
  119.     if Event.What = evCommand then
  120.     begin
  121.       case Event.Command of
  122.         cmNewDialog: NewDialog;
  123.       else
  124.         Exit;
  125.       end;
  126.       ClearEvent(Event);
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Turbo Pascal                           NUMBER  :  668
  141.   VERSION  :  6.0
  142.        OS  :  MS/PC DOS
  143.      DATE  :  August 12, 1992                          PAGE  :  3/4
  144.  
  145.     TITLE  :  Dual Input Lines in Turbo Vision
  146.  
  147.  
  148.  
  149.  
  150.     end;
  151.   end;
  152.  
  153.   procedure TMyApp.InitMenuBar;
  154.   var
  155.     R: TRect;
  156.   begin
  157.     GetExtent(R);
  158.     R.B.Y := R.A.Y + 1;
  159.     MenuBar := New(PMenuBar, Init(R, NewMenu(
  160.       NewSubMenu('~F~ile', hcNoContext, NewMenu(
  161.         NewItem('E~x~it', 'Alt-X', kbAltX, cmQuit, hcNoContext,
  162.         nil)),
  163.       NewSubMenu('~W~indow', hcNoContext, NewMenu(
  164.          NewItem('~D~ialog','F2', kbF2, cmNewDialog, hcmyDialog,
  165.         nil)),
  166.       nil))
  167.     )));
  168.   end;
  169.  
  170.   procedure TMyApp.NewDialog;
  171.   var
  172.     Borland: PView;
  173.     Dialog: PDemoDialog;
  174.     R: TRect;
  175.     C: Word;
  176.   begin
  177.     R.Assign(20, 6, 60, 19);
  178.     Dialog := New(PDemoDialog, Init(R, 'Demo Dialog'));
  179.     with Dialog^ do
  180.     begin
  181.       R.Assign(3, 3, 18, 4);
  182.       Borland := New(PInputLine, Init(R,10));
  183.       Insert(Borland);    { The order of insertion is directly }
  184.                           { related to the order of data items in }
  185.                           { the data structure }
  186.       R.Assign(3, 4, 18, 5);
  187.       Borland := New(PInputLine, Init(R,10));
  188.       Insert(Borland);
  189.       R.Assign(2, 2, 10, 3);
  190.       Insert(New(PLabel, Init(R, 'Cheeses', Borland)));
  191.       R.Assign(22, 3, 34, 5);
  192.       Borland := New(PRadioButtons, Init(R,
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.   PRODUCT  :  Turbo Pascal                           NUMBER  :  668
  207.   VERSION  :  6.0
  208.        OS  :  MS/PC DOS
  209.      DATE  :  August 12, 1992                          PAGE  :  4/4
  210.  
  211.     TITLE  :  Dual Input Lines in Turbo Vision
  212.  
  213.  
  214.  
  215.  
  216.         NewSItem('~R~unny',
  217.         NewSItem('~M~elted',
  218.         nil)))
  219.       );
  220.       Insert(Borland);
  221.       R.Assign(21, 2, 33, 3);
  222.       Insert(New(PLabel, Init(R, 'Consistency', Borland)));
  223.       R.Assign(15, 8, 25, 10);
  224.       Insert(New(PButton, Init(R, '~O~k', cmOk, bfDefault)));
  225.       R.Assign(28, 8, 38, 10);
  226.       Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
  227.     end;
  228.     Dialog^.SetData(RMyData);  { Associate data to dialog }
  229.                                { input lines }
  230.     DeskTop^.Insert(Dialog);
  231.   end;
  232.   var
  233.     MyApp: TMyApp;
  234.  
  235.   begin
  236.  
  237.     MyApp.Init;
  238.     MyApp.Run;
  239.     MyApp.Done;
  240.   end.
  241.  
  242.   DISCLAIMER: You have the right to use this technical information
  243.   subject to the terms of the No-Nonsense License Statement that
  244.   you received with the Borland product to which this information
  245.   pertains.
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.